<?php
set_time_limit(0);
function writeServerFile($target_file, $xml_data, $mode='wb'){
    $oldMask  = umask(0);
    $fp       = @fopen(CLIENT_CONFIG_DIR."/server/data/itemdata.js", $mode);
	$content .="var itemData = [";
    $i=0;
    $len=get_count($xml_data[$i],"id");
	for($j=2;$j<count($xml_data[$i]);$j++){
		if ($xml_data[$i][$j]['id'] != "") {
		$content .= "{";
		$content .= "id:".$xml_data[$i][$j]['id'].",";
		$content .= "name:'".$xml_data[$i][$j]['name']."',";
		$content .= "type:".$xml_data[$i][$j]['type'].",";
		$content .= "typeValue:'".$xml_data[$i][$j]['type_value']."'";
		$content .="}";
		if($j<(count($xml_data[$i])-1))
		$content .=",";
		}
    }
	$content .="];";
	$content .="exports.itemData = itemData;";
	
    fwrite($fp,$content);
    fclose($fp);
    umask($oldMask);
}
?>